package cn.com.headfree.listener;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.sgcc.isc.ualogin.client.listener.IscSingleSignOutHttpSessionListener;

import cn.com.headfree.filter.RedisSessionFilter;

/**
 * Title:统一权限平台的监听器
 * Description:
 * Copyright: Copyright (c) 2017
 * Company: www.headfree.com.cn
 * @author fengya
 * @version 1.0
 * @date  2019年8月6日 上午9:52:46
 */
@Configuration
public class ISCListener {

	/**
	 * 统一权限平台监听
	 * */
	@Bean
	public ServletListenerRegistrationBean<IscSingleSignOutHttpSessionListener> iscSingleSignOutHttpSessionListenerBean(){
		ServletListenerRegistrationBean<IscSingleSignOutHttpSessionListener>
		iscSingleSignOutHttpSessionListener = new ServletListenerRegistrationBean<IscSingleSignOutHttpSessionListener>(new IscSingleSignOutHttpSessionListener());
		return iscSingleSignOutHttpSessionListener;
	}

	/**
	 * @description 加载redis过滤器的配置
	 * @author 冯亚
	 * @date 2019年8月6日 上午9:04:26
	 * @return
	 * FilterRegistrationBean
	 */
	@Bean
    public FilterRegistrationBean<RedisSessionFilter> redisSessionFilterFilter() {
        FilterRegistrationBean<RedisSessionFilter> filterRegistrationBean = new FilterRegistrationBean<RedisSessionFilter>();
        filterRegistrationBean.setOrder(7);
        filterRegistrationBean.setFilter(this.redisSessionFilter());
        filterRegistrationBean.setName("RedisSessionFilter");
        return filterRegistrationBean;
    }

	@Bean
	public RedisSessionFilter redisSessionFilter() {
		return new RedisSessionFilter();
	}
}
